using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableItemUseDao:DaoBase<TableItemUse>
    {
        public override void AddPrimaryIndex(TableItemUse model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableItemUse.txt";
        }

        protected override TableItemUse ParseRowData(string[] rowData)
        {
            TableItemUse data = new TableItemUse();
			data.id = rowData [0];
			data.itemId = rowData [1];
			data.result = rowData [2];

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.odds = 0;
            }
            else
            {
                data.odds = int.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.category = 0;
            }
            else
            {
                data.category = int.Parse(rowData[4]);
            }

            return data;
        }


        public override void AddOneIndex(TableItemUse model)
        {
            if (!cacheOneIndex.ContainsKey(model.itemId.ToString()))
            {
                cacheOneIndex[model.itemId.ToString()] = new List<TableItemUse>();
            }
            cacheOneIndex[model.itemId.ToString()].Add(model);
        }
    

    }

}
